<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="java.util.List"%>
<%@page import="it.fantacalcio.model.Partita"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Iterator"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel=stylesheet href="css/style.css" type="text/css">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
<%@ taglib uri="http://struts.apache.org/tags-logic-el" prefix="logic" %>
<% 
@SuppressWarnings("unchecked")
List<Partita> listaPartita = (List<Partita>) request.getAttribute("listaPartita"); 
%>
<title>Fantacalcio | Calendario</title>
</head>
<body>
	<c:if test="${userInSession == null }">
		<c:redirect url="Logout.do"></c:redirect>
	</c:if>
		
	<c:import url="/head.jsp"/>
	
	<c:import url="/menu.jsp"/>
	
	<div class="menu">
		<c:import url="/menuUtente.jsp"/>
	</div>
	
	<div class="context">
		<h1> Calendario </h1>
		<c:if test="${msg != null }">
			<div class="message">
				<span>${msg}</span>
			</div>
		</c:if>
		<%  
			Partita partita = listaPartita.get(0);
			String data = partita.getDataString(); 
		%>
		<div class="giorno">
			<div class="data"><%=data %></div>
			<div class="squadre">
		<%
			Iterator<Partita> it = listaPartita.iterator();
			while(it.hasNext()){
				partita = it.next();
				if ( !data.equals(partita.getDataString()) ){
					data = partita.getDataString();
		%>
			</div>
		</div>
		<div class="giorno">
			<div class="data"><%=data %></div>
			<div class="squadre">
		<%
				}
		%>
			<div class="squadra">
				<a href="PrepareCRUDPartitaAction.do?codOp=apri&id=<%=partita.getId()%>"><%=partita.getSquadraInCasa() %> - <%=partita.getSquadraFuoriCasa() %></a>
			</div>
		<%
			}
		%>
			</div>
		</div>
		
	</div>
	
	<c:import url="/footer.jsp"/>

</body>
</html>